<include file="Public:header" />
<form action="" method="" class="definewidth m20" id="records-form">
<table class="table table-bordered table-hover definewidth m10">
    <tr>
        <input type="hidden" name="fault_records_id" value="{$fault_records['fault_records_id']}" />
        <td class="tableleft">记录编号</td>
        <td><input type="text" name="records_no" value="{$fault_records['records_no']}" /></td>
    </tr>
    <tr>
        <td class="tableleft">故障设备</td>
        <td>
            <select name="equipment_id">
                <foreach name="equipment" item="equ_val">
                    <option value="{$equ_val['equipment_id']}" <if condition="$fault_records['equipment_id'] eq $equ_val['equipment_id']"> selected </if> >{$equ_val.name}--{$equ_val.number}</option>
                </foreach>
            </select>
        </td>
    </tr>
    <tr>
        <td class="tableleft">故障时间</td>
        <td>
            <input type="date" name="fault_time" value="{$fault_records['fault_time']|date='Y-m-d',###}"/>
        </td>
    </tr>
    <tr>
        <td class="tableleft">故障原因</td>
        <td><input type="text" name="fault_reason" value="{$fault_records['fault_reason']}" /></td>
    </tr>
    <tr>
        <td class="tableleft">处理办法</td>
        <td><input type="text" name="deal_method" value="{$fault_records['deal_method']}" /></td>
    </tr>
    <tr>
        <td class="tableleft">维护后设备状态</td>
        <td><input type="text" name="status" value="{$fault_records['status']}" /></td>
    </tr>
    <input type="hidden" name="reg_time" value="{$fault_records['reg_time']|date='Y-m-d',###}" />
    <tr>
        <td class="tableleft"></td>
        <td>
            <button class="btn btn-primary" type="button" id="add-records">保存</button> &nbsp;&nbsp;<button type="button" class="btn btn-success" name="backid" id="backid">返回列表</button>
        </td>
    </tr>
</table>
</form>

<script>
    $(function () {
        $('#backid').click(function(){
            window.location.href="{:U('Home/FaultRecords/index')}";
        });

        $("#add-records").click(function () {
            data = $("#records-form").serialize();
            $.post(
                    "{:U('Home/FaultRecords/save')}",
                    data,
                    function(xhr){
                        if(200 == xhr.status){
                            alert(xhr.msg);
                            location.href = "{:U('Home/FaultRecords/index')}"
                        }else {
                            alert(xhr.msg);
                        }
                    }
            );
        });

    });
</script>

<include file="Public:footer" />